export { }
/**
 * 差集
 */
export type SetDifference<A, B> = A extends B ? never : A;
type A = string | number;
type B = number | boolean;
type AB = SetDifference<A, B>

//Omit 忽略某些属性
type Omit<T, K extends keyof any> = Pick<T, SetDifference<keyof T, K>>;

type Props = { name: string, age: number, visible: boolean }
type OmitAgeProps = Omit<Props, 'age'>

namespace na {
	type Diff<T extends Object, U extends Object> = Pick<T, SetDifference<keyof T, keyof U>>
	type Props = { name: string, age: number, visible: boolean }
	type DefaultProps = { age: number }
	type DiffProps = Diff<Props, DefaultProps>
}

namespace nb {
	// InterSection 交叉属性
	type InterSection<T extends Object, U extends Object> = Pick<T, Extract<keyof T, keyof U> & Extract<keyof U, keyof T>>
	type Props = { name: string, age: number, visible: boolean }
	type DefaultProps = { age: number }
	type DuplicateProps = InterSection<Props, DefaultProps>
}
namespace nc {
	//Overwrite
	type Diff<T extends Object, U extends Object> = Pick<T, SetDifference<keyof T, keyof U>>
	type InterSection<T extends Object, U extends Object> = Pick<T, Extract<keyof T, keyof U> & Extract<keyof U, keyof T>>
	type Overwrite<
		T extends Object,
		U extends Object,
		I = Diff<T, U> & InterSection<U, T>
		> = Pick<I, keyof I>
	type OldProps = { name: string, age: number, visible: boolean }
	type NewProps = { age: number, visible: boolean }
	type ReplaceProps = Overwrite<OldProps, NewProps>
}
namespace nd {
	//Merge = Compute +Omit<U,T>
	type O1 = {
		id: number
		name: string
	}
	type O2 = {
		id: number
		age: number
	}

	type Compute<A extends any> = A extends Function ? A : { [K in keyof A]: A[K] }
	type R1 = Compute<{ x: 'x' } & { y: 'y' }>
	type Merge<O1 extends object, O2 extends object> = Compute<
		O1 & Omit<O2, keyof O1>
	>;

	type R2 = Merge<O1, O2>;

}

namespace ne{
	//将 T 的所有属性的 readonly 移除
	type Mutable<T> = {
		-readonly [P in keyof T]: T[P]
	}
}